package com.jeesite.modules.exam.orgselect.service;

import java.util.List;

import com.jeesite.common.lang.StringUtils;
import com.jeesite.common.service.ServiceException;
import com.jeesite.modules.exam.socreResult.entity.DcSupExamOrgSelect;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.jeesite.common.entity.Page;
import com.jeesite.common.service.CrudService;
import com.jeesite.modules.exam.orgselect.dao.DcExamOrgSelectDao;

/**
 * dc_sup_exam_org_selectService
 * @author xhc
 * @version 2022-08-01
 */
@Service
@Transactional(readOnly=false)
public class DcExamOrgSelectService extends CrudService<DcExamOrgSelectDao, DcSupExamOrgSelect> {
	
	/**
	 * 获取单条数据
	 * @param dcSupExamOrgSelect
	 * @return
	 */
	@Override
	public DcSupExamOrgSelect get(DcSupExamOrgSelect dcSupExamOrgSelect) {
		return super.get(dcSupExamOrgSelect);
	}
	
	/**
	 * 查询分页数据
	 * @param dcSupExamOrgSelect 查询条件
	 * @param dcSupExamOrgSelect.page 分页对象
	 * @return
	 */
	@Override
	public Page<DcSupExamOrgSelect> findPage(DcSupExamOrgSelect dcSupExamOrgSelect) {
		return super.findPage(dcSupExamOrgSelect);
	}
	
	/**
	 * 查询列表数据
	 * @param dcSupExamOrgSelect
	 * @return
	 */
	@Override
	public List<DcSupExamOrgSelect> findList(DcSupExamOrgSelect dcSupExamOrgSelect) {
		return super.findList(dcSupExamOrgSelect);
	}
	
	/**
	 * 保存数据（插入或更新）
	 * @param dcSupExamOrgSelect
	 */
	@Override
	@Transactional(readOnly=false)
	public void save(DcSupExamOrgSelect dcSupExamOrgSelect) {
		DcSupExamOrgSelect dcSupExamOrgSelectParam = new DcSupExamOrgSelect();
		dcSupExamOrgSelectParam.setOrgCode(dcSupExamOrgSelect.getOrgCode());
		DcSupExamOrgSelect dcSupExamOrgSelecDb = dao.getByEntity(dcSupExamOrgSelectParam);
		if(dcSupExamOrgSelecDb!=null&&StringUtils.equals(dcSupExamOrgSelecDb.getOrgStatus(),"0")){
			throw new ServiceException("机构已存在");
		}
		if(dcSupExamOrgSelecDb!=null){
			dcSupExamOrgSelect.setId(dcSupExamOrgSelecDb.getId());
			dcSupExamOrgSelect.setIsNewRecord(false);
		}
		dcSupExamOrgSelect.setOrgStatus("0");
		super.save(dcSupExamOrgSelect);
	}
	
	/**
	 * 更新状态
	 * @param dcSupExamOrgSelect
	 */
	@Override
	@Transactional(readOnly=false)
	public void updateStatus(DcSupExamOrgSelect dcSupExamOrgSelect) {
		super.updateStatus(dcSupExamOrgSelect);
	}
	
	/**
	 * 删除数据
	 * @param dcSupExamOrgSelect
	 */
	@Override
	@Transactional(readOnly=false)
	public void delete(DcSupExamOrgSelect dcSupExamOrgSelect) {
		super.delete(dcSupExamOrgSelect);
	}
	
}